package com.example.demo.dao;

import com.example.demo.pojo.Book;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;


import java.util.List;

@Repository
public interface BookDAO {
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "author", column = "author"),
            @Result(property = "subject", column = "subject"),
            @Result(property = "publish", column = "publish")
    }
    )
    @Select("select * from book where name like concat('%',#{name},'%')")
    List<Book> findBooks(String name);

    @Update("update book set name= #{name}, author = #{author} where id = #{id}")
    void updateBook(Book theBook);

    @Delete("delete from book where id = #{id}")
    void deleteBook(String id);
}
